package cn.feng.rabbitmq.spring;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author Administrator
 */
public class SpringMain {

    public static void main(final String... args) throws Exception {
       System.out.println("---");
       @SuppressWarnings("resource")
		AbstractApplicationContext ctx = new ClassPathXmlApplicationContext(
               "classpath:spring/rabbitmq-context.xml");
       //RabbitMQ模板
       RabbitTemplate template = ctx.getBean(RabbitTemplate.class);
       //发送消息
       template.convertAndSend("Hello, world!-----lrf");
       Thread.sleep(1000);// 休眠1秒
		ctx.destroy(); // 容器销毁
	}
}
